﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using University.Workshop.Model;
using University.Workshop.Business;
using System.Data.SqlClient;

namespace University.Workshop.Presenters.PatientFolder
{
    public class PresenterPatient
    {
        IPatient view;

        public PresenterPatient(IPatient view)
        {
            this.view = view;
        }

        public string AddPatient()
        {
            Patient patient = new Patient(view.PatientId, view.FirstName, view.FatherLastName, view.MotherLastName, view.LandPhone, view.CellPhone, view.Address, view.GroupMember);
            try
            {  
                if(!PatientManager.MandatoryFields(patient))
                    return "Todos los espacios son obligatorios";
                else
                    PatientManager.PatientRegister(patient);
                    return "El paciente se registro con exito";
            }
            catch (EvaluateException ex)
            {
               return "Error al registrar el paceinte"+ex;
            }
        }

        public static bool Cleaner(string message)
        {
            if (PatientManager.CleanSpaces(message))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
